<?php

namespace common\models\user;

use Yii;

/**
 * This is the model class for table "{{%user_authent}}".
 *
 * @property int $id
 * @property int $user_id 用户ID
 * @property string $realname 真实姓名
 * @property int $gender 性别
 * @property int $photo 性别
 * @property int $ict_id 证件类型
 * @property string $idcardno 证件号
 * @property string $idcardno_hash 证件号
 * @property string $birthday 出生日期
 * @property int $reason 审核失败原因
 * @property int $status 认证状态
 * @property int $created_at 认证时间
 * @property int $updated_at 最后更新时间
 */
class UserAuthent extends \common\db\ActiveRecord {

    use \common\traits\TimestampBehavior;

    /**
     * @const GENDERA_FEMALE 女
     * @const GENDERA_MALE 男
     */
    const GENDER_FEMALE = 0;
    const GENDER_MALE = 1;

    const STATUS_DEFAULT = 0;
    const STATUS_SUCCESS = 1;
    const STATUS_FAIL = -1;

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return '{{%user_authent}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['user_id', 'ict_id', 'created_at', 'updated_at'], 'integer'],
            [['realname', 'idcardno', 'idcardno_hash'], 'required'],
            [['birthday'], 'safe'],
            [['realname'], 'string', 'max' => 50],
            [['gender', 'status'], 'string', 'max' => 1],
            ['idcardno_hash', 'string', 'max' => 255],
            ['reason', 'string', 'max' => 255],
            ['photo', 'string', 'max' => 120],
            [['idcardno'], 'string', 'max' => 32],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '用户ID',
            'realname' => '真实姓名',
            'gender' => '性别',
            'photo' => '头像',
            'ict_id' => '证件类型',
            'idcardno' => '证件号',
            'idcardno_hash' => '证件号',
            'birthday' => '出生日期',
            'reason' => '审核失败原因',
            'status' => '认证状态',
            'created_at' => '认证时间',
            'updated_at' => '最后更新时间',
        ];
    }

}
